package com.approval.approvalapp.message.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.MessageListBean;
import com.approval.approvalapp.bean.NoticeBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by louyulin on 2019/5/31.
 */

public class ChrvAdapter extends RecyclerView.Adapter<ChrvAdapter.Holder> {

    List<NoticeBean.MemberListBean> list;

    public void setList(List<NoticeBean.MemberListBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.chry_item,parent,false);
        Holder holder = new Holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
        holder.tvName1.setText((position + 1) + "");
        holder.tvName2.setText(list.get(position).getFk_name());
        if (list.get(position).getIFCH() == 0){
            holder.tvName3.setText("未确认");
        }else if (list.get(position).getIFCH() == 1){
            holder.tvName3.setText("确认参会");
        }else {
            holder.tvName3.setText(list.get(position).getJoin_info());
        }
        holder.tvName4.setText(list.get(position).getFk_time());
        holder.tvName5.setText(list.get(position).getSign_name());
        holder.tvName6.setText(list.get(position).getSign_time());

    }

    @Override
    public int getItemCount() {
        if (list == null){
            return 0;
        }else {
            return list.size();
        }
    }

    class Holder extends RecyclerView.ViewHolder{
        @Bind(R.id.tv_name1)
        TextView tvName1;
        @Bind(R.id.tv_name2)
        TextView tvName2;
        @Bind(R.id.tv_name3)
        TextView tvName3;
        @Bind(R.id.tv_name4)
        TextView tvName4;
        @Bind(R.id.tv_name5)
        TextView tvName5;
        @Bind(R.id.tv_name6)
        TextView tvName6;
        public Holder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
